package com.ternnetwork.core.notice.repository;


import com.ternnetwork.core.notice.entity.NoticeCategory;
import com.ternnetwork.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface NoticeCategoryRepository extends BaseRepository<NoticeCategory, Long> {

    @Query("select count(1) from NoticeCategory where name=?1 and parentId=?2")
    Long getCountByNameAndParentId(String name,Long parentId);

    @Query("select count(1) from NoticeCategory where name=?1 and parentId=?2 and id!=?3")
    Long getCountByNameAndParentIdAndExcludeId(String name,Long parentId,Long excludeId);

    @Query("from NoticeCategory")
    List<NoticeCategory> findAll();

    @Query("select count(1) from NoticeCategory where  parentId=?1")
    Long getCountByParentId(Long parentId);


}
